﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Prism.Games.GalEngine.Scripts.Data.SceneElements;
using System.IO;

namespace Prism.Games.GalEngine.Scripts.Parser
{
    public class SystemSoundParser
    {
        public SystemSoundParser()
            : base()
        {
            this.Counter = -1;
            this.EffectSoundManager = new Audio.AudioManager(Helper.AudioBase.AudioFactory, Helper.AudioBase.SEPlaybackLatency);
        }

        public void ChangeVolume(float volume)
        {
            this.EffectSoundManager.Volume = volume;
        }

        public virtual void Restart()
        {
            this.EffectSoundManager.Reset();
        }

        public Audio.AudioManager EffectSoundManager { get; set; }

        public void LoadAllSE()
        {
            var fs = new FileStream(GameFrameLibrary.SystemSoundUris.MouseOver.Content.LocalPath, FileMode.Open);
            this.Counter++;
            this.EffectSoundManager.Load(fs, this.Counter);
        }

        public void PlaySystemSound(GameFrameLibrary.SystemSound sound)
        {
            if (sound != null)
                this.EffectSoundManager.BeginPlay(sound.Id);
        }

        public int Counter { get; set; }
    }
}
